import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { KpiRecordVO, KpiRecordForm, KpiRecordQuery } from '@/api/manu/kpiRecord/types';

/**
 * 查询记录列表
 * @param query
 * @returns {*}
 */

export const listKpiRecord = (query?: KpiRecordQuery): AxiosPromise<KpiRecordVO[]> => {
  return request({
    url: '/manu/kpiRecord/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询记录详细
 * @param id
 */
export const getKpiRecord = (id: string | number): AxiosPromise<KpiRecordVO> => {
  return request({
    url: '/manu/kpiRecord/' + id,
    method: 'get'
  });
};

/**
 * 新增记录
 * @param data
 */
export const addKpiRecord = (data: KpiRecordForm) => {
  return request({
    url: '/manu/kpiRecord',
    method: 'post',
    data: data
  });
};

/**
 * 修改记录
 * @param data
 */
export const updateKpiRecord = (data: KpiRecordForm) => {
  return request({
    url: '/manu/kpiRecord',
    method: 'put',
    data: data
  });
};

/**
 * 删除记录
 * @param id
 */
export const delKpiRecord = (id: string | number | Array<string | number>) => {
  return request({
    url: '/manu/kpiRecord/' + id,
    method: 'delete'
  });
};

export const setKpiRecordAsDefault = (ids: Array<string | number>) => {
  return request({
    url: '/manu/kpiRecord/setDefault',
    method: 'post',
    data: ids
  });
}  
